package com.share.design.template;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * author:caifan
 * date:2020/2/5
 */
public abstract class Calculator {

    public Integer getResult(String exp, String operator) {
        String[] split = exp.split(operator);
        List<Integer> numbers = Arrays.asList(split).stream().map(num -> Integer.parseInt(num.trim())).collect(Collectors.toList());
        return calculate(numbers);
    }

    public abstract Integer calculate(List<Integer> numbers);
}
